import zzb from 'zzbjssdk'
import Index from './Index.vue'
import Vue from 'vue'
//需要在浏览器中展示时放开这段注释
//import zzbjsBrowserBoot from 'zzbjs-browser-boot'
Vue.directive('real-img', async function (el, binding) { // 指令名称为：real-img
  let imgURL = binding.value // 获取图片地址
  if (imgURL) {
    let exist = await imageIsExist(imgURL)
    if (exist) {
      el.setAttribute('src', imgURL)
    }
  }
})
let imageIsExist = function (url) {
  return new Promise((resolve) => {
    var img = new Image()
    img.onload = function () {
      if (this.complete === true) {
        resolve(true)
        img = null
      }
    }
    img.onerror = function () {
      resolve(false)
      img = null
    }
    img.src = url
  })
}
zzb.vue({
  el: '#app',
  components: { Index },
  template: '<Index/>'
})
//需要在浏览器中展示时放开这段注释
//zzbjsBrowserBoot.init();
